<?php
/*
 * Creative Bulletin Board Generation 3
 * Version 1.0 Beta 1
 +------------------------------------
 * User Application Controller: Permission Value
 * Started: September 24, 2009 5:58 PM (Week 1, Day...6?)
 * Script version: 1.0
 */
class permissionvalue{
	public function __construct($key, $pmask){
		global $db, $main;
		$this->key = $main->secure_string($key);
		$this->pmask = intval($pmask);
		$query = $db->select("permission_values", "*", "1", " WHERE `key` = '{$this->key}' AND `mask` = '{$this->pmask}'");
		if($query){
			if($db->num_rows($query) == 0){
				$this->status = false;
			}
			else{
				$this->value = $db->fetch_array($query);
				$this->status = true;
			}
		}
		else{
			$this->status = false;
		}
	}
	
	public function getStatus(){
		return $this->status;
	}
	
	public function getID(){
		return $this->value['id'];
	}
	
	public function getMask(){
		return $this->value['mask'];
	}
	
	public function getKey(){
		return $this->value['key'];
	}
	
	public function getValue(){
		return $this->value['value'];
	}
	
	public function delete(){
		global $db;
		$query = $db->query("DELETE FROM `".DB_PREFIX."permission_values` WHERE `id` = {$this->value['id']} LIMIT 1");
		return $query;
	}
}
